Attribute VB_Name = "MStandardCode"
''' VBA Code Documentor 5.0 by Rob Bovey, copyright 1996-2004,
''' all rights reserved. May be redistributed for free,
''' but may not be sold without the author's explicit permission.
Option Explicit
Option Private Module

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' Comments:   Substitutes strings from an array into a main string in place
'''             of token characters (gszTOKEN). There must be the same number
'''             of items in the array as there are gszTOKEN characters in the
'''             main string.
'''
''' Arguments:  szMessage   [in] String including replacement characters
'''             vaszSubText [in] An array of strings to substitute
'''
''' Returns:    String      The final text.
'''
''' Date        Developer           Action
''' --------------------------------------------------------------------------
''' 10/05/98    Rob Bovey           Created
'''
Public Function szSubstituteText(ByVal szMessage As String, ParamArray vaszSubText() As Variant) As String

    Dim lPos As Long
    Dim lCount As Long
    
    ''' Set position to 1st character
    lPos = 1
    
    ''' Do replacement on error message
    For lCount = LBound(vaszSubText) To UBound(vaszSubText)
        ''' Find the replacement key
        lPos = InStr(lPos, szMessage, gszTOKEN)
        ''' Bail out if there are no more tokens to replace.
        If lPos = 0 Then Exit For
        ''' Replace it with the text
        szMessage = Left$(szMessage, lPos - 1) & CStr(vaszSubText(lCount)) & Right$(szMessage, Len(szMessage) - lPos)
        lPos = lPos + 1
    Next lCount

    ''' Return the processed message.
    szSubstituteText = szMessage
    
End Function


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' Comments:   Restores all critical application properties.
'''
''' Arguments:  lCalcMode   [in] (Optional) If calc mode was changed and needs
'''                         to be restored, pass the setting to restore.
'''                         If nothing is passed, calc mode will not be changed.
'''
''' Date        Developer           Action
''' --------------------------------------------------------------------------
''' 01/10/00    Rob Bovey           Created
'''
Public Sub ResetAppProperties(Optional ByVal lCalcMode As Long = 0)

    Application.StatusBar = False
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    Application.EnableEvents = True
    Application.Cursor = xlDefault
    
    If lCalcMode <> 0 Then
        If Application.ActiveWorkbook Is Nothing Then ThisWorkbook.Activate
        Application.Calculation = lCalcMode
    End If

End Sub


Public Function bIsProjectProtected() As Boolean
    Dim objProject As VBIDE.VBProject
    On Error Resume Next
    Set objProject = ThisWorkbook.VBProject
    bIsProjectProtected = (objProject Is Nothing)
End Function
